from database_helper import DBHelper


class DatabaseOperation:
    def __init__(self):
        self.dbHelper = DBHelper()

    def createUnconfirmedDataTable(self):
        create_table_sql = "create table if not EXISTS unconfirmed_data(id int primary key auto_increment," \
                           "stu_name varchar(20)," \
                           "stu_gender varchar(10)," \
                           "stu_id varchar(50)," \
                           "original_school varchar(50)," \
                           "original_major varchar(50)," \
                           "target_school varchar(50)," \
                           "target_school_id varchar(20)," \
                           "target_academy varchar(50)," \
                           "target_academy_id varchar(20)," \
                           "target_major varchar(50)," \
                           "target_major_id varchar(20)," \
                           "study_direction varchar(50)," \
                           "study_direction_id varchar(20)," \
                           "if_no_exam varchar(10)," \
                           "recommend_type varchar(20)," \
                           "study_type varchar(20)," \
                           "study_source varchar(20)," \
                           "politic_score varchar(15)," \
                           "forign_score varchar(15)," \
                           "major1_score varchar(15)," \
                           "major2_score varchar(15)," \
                           "first_score varchar(20)," \
                           "second_writen varchar(20)," \
                           "second_oral varchar(20)," \
                           "second_interview varchar(20)," \
                           "second_score varchar(20)," \
                           "final_score varchar(20)," \
                           "years varchar(10)," \
                           "tutor_name varchar(20)," \
                           "remark varchar(500)," \
                           "file_type varchar(50)," \
                           "from_file varchar(200)," \
                           "from_table varchar(50))"
        self.dbHelper.createTable(create_table_sql)

    def insertUnconfirmedDataTable(self,**data):
        insert_sql = "insert into unconfirmed_data" \
                   "(stu_name," \
                   "stu_gender," \
                   "stu_id," \
                   "original_school," \
                   "original_major," \
                   "target_school," \
                   "target_school_id," \
                   "target_academy," \
                   "target_academy_id," \
                   "target_major," \
                   "target_major_id," \
                   "study_direction," \
                   "study_direction_id," \
                   "if_no_exam," \
                   "recommend_type," \
                   "study_type," \
                   "study_source," \
                   "politic_score," \
                   "forign_score," \
                   "major1_score," \
                   "major2_score," \
                   "first_score," \
                   "second_writen," \
                   "second_oral," \
                   "second_interview," \
                   "second_score," \
                   "final_score," \
                   "years," \
                   "tutor_name," \
                   "remark," \
                   "file_type," \
                   "from_file," \
                   "from_table)" \
                   "values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        params = [" " for item in range(33)]

        # 数据匹配函数


        self.dbHelper.insert(insert_sql, *params)


